package cn.edu.lcu.cs.architecture.pipe.ore_tcp;

import java.io.IOException;
import java.io.ObjectInputStream;
import java.net.Socket;
import java.net.UnknownHostException;

import static cn.edu.lcu.cs.architecture.pipe.ore_tcp.Constants.*;

/**
 * @Author Ling
 * @Date 2021/11/27 23:17
 * @Version 1.0
 */
public class WasteYard {
    private long amount;

    public static void main(String[] args) {
        new WasteYard().run();
    }

    private void run() {
        try (Socket client = new Socket(SERVER_NAME, SOCKET_PORT_MINE);
             ObjectInputStream in = new ObjectInputStream(client.getInputStream())) {
            while (true) {
                Ore ore = (Ore) in.readObject();
                System.out.println("废料：" + amount++ + "\t" + ore);
            }
        } catch (UnknownHostException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }
    }
}
